<?php

class Rating {
	
	private $id_rating;
	private $method_recommendation;
	private $score;
	private $id_title;
	private $id_user;
	private $time;
	
	public function __construct($map=array()) {
		
		$this->id_rating = isset($map['id_rating']) ? $map['id_rating'] : null ;
		$this->method_recommendation = isset($map['method_recommendation']) ? $map['method_recommendation'] : null ;
		$this->score = isset($map['score']) ? $map['score'] : NON_NOTE;
		$this->time = isset($map['time']) ? $map['time'] : date("Y-m-d H:i:s");
		$this->id_title = isset($map['id_title']) ? $map['id_title'] : null ;
		$this->id_user =  isset($map['id_user']) ? $map['id_user'] : $_SESSION['infosAuth']->getIdUser();
	}
	
	public function update($data){
		
		if (isset($data['method_recommendation']))
			$this->setMethodRecommendation($data['method_recommendation']);
		if (isset($data['score']))
			$this->setScore($data['score']);
		if (isset($data['id_title']))
			$this->setIdTitle($data['id_title']);
		
	}
	
	// Getter
	public function getIdRating(){
		return $this->id_rating;
	}
	public function getScore(){
		return $this->score;
	}
	public function getTime(){
		return $this->time;
	}
	public function getIdTitle(){
		return $this->id_title;
	}
	public function getIdUser(){
		return $this->id_user;
	}
	public function getMethodRecommendation(){
		return $this->method_recommendation;
	}
	
	// Setter
	public function setScore($score){
		$this->score = $score;
		$this->updateTime();
	}
	public function setIdTitle($title){
		$this->id_title = $title;
	}
	
	public function setMethodRecommendation($method){
		$this->method_recommendation=$method;
	}
	
	public function updateTime(){
		$this->time = date("Y-m-d H:i:s");	
	}
	
	public function setIdRating($id){
		$this->id_rating = $id;
	}
	
}

?>